package cn.wolfcode.crm.domain;

import cn.wolfcode.crm.util.DateUtil;
import cn.wolfcode.crm.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Setter@Getter
public class CustomerTraceHistory extends BaseDomain{

    @DateTimeFormat(pattern = "y-M-d")
    private Date traceTime;

    private String traceDetails;

    private Systemdictionaryitem traceType;

    private Integer traceResult;

    private String remark;// 备注

    private Customer customer;

    private Employee inputUser;

    private Date inputTime;

    public String getJson() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", customer.getName());
        map.put("traceTime", DateUtil.formatDate(traceTime));
        map.put("traceDetails", traceDetails);
        map.put("traceTypeId", traceType.getId());
        map.put("traceResult", traceResult);
        map.put("remark", remark);
        return JSONUtil.toJSONString(map);
    }

    public String getTraceResultName(){
        String res = "优";
        if (this.traceResult==2){
            res = "中";
        }else if (this.traceResult==1){
            res = "差";
        }
        return res;
    }
}